package com.xbao.controller;

import com.xbao.core.http.CommRequest;
import com.xbao.model.req.SubjectReq;
import com.xbao.service.OssService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

/**
 * Created by qingshengzheng on 2019/1/22.
*/
@Api(value = "/file", tags = "file")
@RequestMapping(value = "file")
@Controller
@EnableAutoConfiguration
public class OssController extends BaseController {
    @Resource
    private OssService ossService;

    @ApiOperation(value = "upload", notes = "upload")
    @RequestMapping(value = "/upload",method = RequestMethod.POST)
    @ResponseBody
    public Object upload(@RequestParam("file") MultipartFile file,@RequestParam("target")Integer target,@RequestParam("type")Integer fileType) {
        String a =file.getOriginalFilename();
        ossService.uploadByInputStream(target,fileType,file);
        return result();
    }
}
